<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('预算科目')" />
	<th:block th:include="include :: layout-latest-css" />
	<th:block th:include="include :: ztree-css" />
</head>
<body class="gray-bg">
	<div class="ui-layout-west">
		<div class="box box-main">
			<div class="box-header">
				<div class="box-title">
					<i class="fa icon-grid"></i> 预算科目
				</div>
				<div class="box-tools pull-right">
				    <a type="button" class="btn btn-box-tool" href="#"  title="预算科目"><i class="fa fa-edit"></i></a>
					<button type="button" class="btn btn-box-tool" id="btnExpand" title="展开" style="display:none;"><i class="fa fa-chevron-up"></i></button>
					<button type="button" class="btn btn-box-tool" id="btnCollapse" title="折叠"><i class="fa fa-chevron-down"></i></button>
					<button type="button" class="btn btn-box-tool" id="btnRefresh" title="刷新科目"><i class="fa fa-refresh"></i></button>
				</div>
			</div>
			<div class="ui-layout-content">
				<div id="tree" class="ztree"></div>
			</div>
		</div>
	</div>
	
	<div class="ui-layout-center">
		<div class="container-div">
			<div class="row">
				<div class="col-sm-12 search-collapse">
					<form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>预算科目：</label>
                                <input type="text" name="yskm"/>
                            </li>
                            <li>
                                <label>科目名称：</label>
                                <input type="text" name="yskmmc"/>
                            </li>
                            <li>
                                <label>上级编码：</label>
                                <input type="text" id="sjyskm" name="sjyskm"/>
                            </li>
                            <li>
                                <label>级次：</label>
                                <input type="text" name="jc"/>
                            </li>
                            <li>
                                <label>是否末级：</label>
                                <select name="sfmj" id="sfmj">
                                    <option value="">全部</option>
								    <option value="0">否</option>
									<option value="1">是</option>
								</select>
                            </li>
                            <li>
                                <label>科目类别</label>
                                <select name="kmlb" id="kmlb">
                                    <option value="">全部</option>
								    <option value="0">收入分类</option>
									<option value="1">支出功能分类</option>
									<option value="2">支出经济分类</option>
								</select>
                            </li>
                            <li>
                                <label>启用标志：</label>
                                <select name="qybz" id="qybz">
                                	<option value="">全部</option>
								    <option value="0">启用</option>
									<option value="1">停用</option>
								</select>
                            </li>
                            <li>
                                <label>有效标志：</label>
                                <select name="yxbz" id="yxbz">
                                	<option value="">全部</option>
								    <option value="0">有效</option>
									<option value="1">无效</option>
								</select>
                            </li>
                           <li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
							    <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
                        </ul>
                    </div>
                </form>
				</div>
				
		        <div class="btn-group-sm" id="toolbar" role="group">
		        	<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:yskm:add">
                    <i class="fa fa-plus"></i> 新增
					</a>
					<a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:yskm:edit">
						<i class="fa fa-edit"></i> 修改
					</a>
		            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:yskm:remove">
		                <i class="fa fa-remove"></i> 删除
		            </a>
		        </div>
		        
		        <div class="col-sm-12 select-table">
				    <table id="bootstrap-table"></table>
				</div>
			</div>
		</div>
	</div>
	
	<th:block th:include="include :: footer" />
	<th:block th:include="include :: layout-latest-js" />
	<th:block th:include="include :: ztree-js" />
	<script th:inline="javascript">
		var addFlag = [[${@permission.hasPermi('system:yskm:add')}]];
        var editFlag = [[${@permission.hasPermi('system:yskm:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:yskm:remove')}]];
        var prefix = ctx + "system/yskm";

		$(function() {
		    var panehHidden = false;
		    if ($(this).width() < 769) {
		        panehHidden = true;
		    }
		    $('body').layout({ initClosed: panehHidden, west__size: 350 });
		    queryUserList();
		    queryDeptTree();
		});

		function queryUserList() {
		     var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add/{id}",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove/{id}",
                exportUrl: prefix + "/export",
                modalName: "预算科目",
                columns: [{
		            checkbox: true
		        },  {
                    field: 'yskm',
                    title: '预算科目编码',
                    align: 'left'
                },
                {
                    field: 'yskmmc',
                    title: '预算科目名称',
                    align: 'left'
                },
                {
                    field: 'zzsj',
                    title: '终止时间',
                    align: 'left'
                },
                {
                    field: 'sjyskm',
                    title: '上级编码',
                    align: 'left'
                },
                {
                    field: 'jc',
                    title: '级次',
                    align: 'left'
                },
                {
                    field: 'sfmj',
                    title: '是否末级',
                    align: 'left',
		        	formatter: function (value, row, index) {
		        		return sfmj(row);
		        	}
                },
                {
                    field: 'kmlb',
                    title: '预算科目类别',
                    align: 'left',
		        	formatter: function (value, row, index) {
		        		return kmlb(row);
		        	}
                },
                {
                    field: 'bz',
                    title: '备注',
                    align: 'left'
                },
                {
                    field: 'qybz',
                    title: '启用标志',
                    align: 'left',
		        	formatter: function (value, row, index) {
		        		return qybz(row);
		        	}
                },
                {
                    field: 'yxbz',
                    title: '有效标志',
                    align: 'left',
		        	formatter: function (value, row, index) {
		        		return yxbz(row);
		        	}
                },
                {
                    title: '操作',
                    align: 'center',
                    align: 'left',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.yskm + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-info  btn-xs ' + addFlag + '" href="javascript:void(0)" onclick="$.operate.add(\'' + row.yskm + '\')"><i class="fa fa-plus"></i>新增</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.yskm + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
			$.table.init(options);
		}
		
		/* 用户状态显示 */
		function kmlb(row) {
		    if (row.kmlb == 0) {
		    	return '<span class="label label-primary">收入分类</span> ';	
    		} else if (row.kmlb == 1) {
		    	return '<span class="label label-primary">支出功能分类</span> ';	
    		}else if (row.kmlb == 2) {
		    	return '<span class="label label-primary">支出经济分类</span> ';	
    		}
		}
		/* 用户状态显示 */
		function sfmj(row) {
		    if (row.sfmj == 1) {
		    	return '<i class=\"fa fa-toggle-on text-info fa-2x\"></i> ';
    			
    		} else {
    			return '<i class=\"fa fa-toggle-off text-info fa-2x\"></i> ';
    		}
		}
		/* 用户状态显示 */
		function qybz(row) {
		    if (row.qybz == 0) {
		    	return '<i class=\"fa fa-toggle-on text-info fa-2x\"></i> ';
    			
    		} else {
    			return '<i class=\"fa fa-toggle-off text-info fa-2x\"></i> ';
    		}
		}
		/* 用户状态显示 */
		function yxbz(row) {
		    if (row.yxbz == 0) {
		    	return '<i class=\"fa fa-toggle-on text-info fa-2x\"></i> ';
    			
    		} else {
    			return '<i class=\"fa fa-toggle-off text-info fa-2x\"></i> ';
    		}
		}
		function queryDeptTree()
		{
			var url = ctx + "system/yskm/treeData";
			var options = {
		        url: url,
		        expandLevel: 1,
		        onClick : zOnClick
		    };
			$.tree.init(options);
			
			function zOnClick(event, treeId, treeNode) {
				//$("#yskm").val(treeNode.id);
				$("#sjyskm").val(treeNode.pId);
				$.table.search();
			}
		}
		
		$('#btnExpand').click(function() {
			$._tree.expandAll(true);
		    $(this).hide();
		    $('#btnCollapse').show();
		});
		
		$('#btnCollapse').click(function() {
			$._tree.expandAll(false);
		    $(this).hide();
		    $('#btnExpand').show();
		});
		
		$('#btnRefresh').click(function() {
			queryDeptTree();
		});
		
	</script>
</body>
</html>